package com.example.demo.Control;

import com.example.demo.Entity.User;
import com.example.demo.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RequestMapping("/u")//类似servlet中的 @WebService("/u")，指定路径
@RestController  //@ResponseBody+@Controller
 //@ResponseBody 返回的Body不是html页面，是JSON字符串
public class UserControl {
    @Autowired //属性注入 将UserService存储到Spring容器中
    public UserService userService;
    @RequestMapping("/getall")
    public List<User> getAll(){
        return userService.getAll();
    }
}
